<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../../Template/generalTemplate.xhtml">


            <ui:define name="content">
                <h:form>

                    <p:panel id="invoiceList" header="Invoices List" style="height:495px;">
                        <div style="margin-top:10px;margin-left:20px;margin-right:20px;height:430px;overflow: auto;"> 

                            <p:dataTable id="Invoice" dynamic="true" emptyMessage="No Invoice Has Been Created" value="#{viewAllInvoicesManagedBean.getAllInvoices()}" var ="o" paginator="true" rows="4">
                                <p:column filterBy="#{o.id}" filterMatchMode="contains">
                                    <f:facet name="header">Invoice ID</f:facet>
                                    #{o.id}
                                </p:column>
                                <p:column filterBy="#{o.invoiceType}" filterMatchMode="contains">
                                    <f:facet name="header">Type</f:facet>
                                    #{o.invoiceType}
                                </p:column>
                                <p:column filterBy="#{o.deliveryOrder.id}" filterMatchMode="contains"
                                          headerText="Delivery Order ID:">
                                    <h:outputText value="#{o.deliveryOrder.id}"/>
                                </p:column>

                                <p:column filterBy="#{o.deliveryOrder.parentSalesOrder.customer.name}" filterMatchMode="contains">
                                    <f:facet name="header">Company</f:facet>
                                    #{o.deliveryOrder.parentSalesOrder.customer.name}
                                </p:column>  
                                <p:column>
                                    <f:facet name ="header">Status</f:facet> 
                                    <h:outputText rendered ="#{o.abolished}" style="color:red;" value="Abolished"/>
                                    <h:outputText rendered ="#{!o.isPaid}" value= "Processing"/>
                                    <h:outputText rendered ="#{o.isPaid}" style="color:blue;" value= "Paid"/>
                                </p:column>

                                <p:column style="width:100px;text-align:center;">
                                    <f:facet name="header">Action</f:facet>

                                    <p:commandButton action ="#{viewAllInvoicesManagedBean.viewInvoice(o)}"  image="ui-icon ui-icon-search" title="View">  
                                    </p:commandButton>

                                </p:column>        
                            </p:dataTable>



                            <p:fieldset legend="View Abolished Invoices" toggleable="true" toggleSpeed="500"  
                                        toggleListener="#{viewAllInvoicesManagedBean.handleToggle}"  
                                        onToggleUpdate="deliveryInfo" collapsed="true" style="margin-top:20px;">  

                                <p:dataTable id="AbolishInvoice" dynamic="true" emptyMessage="No Invoice in this list" value="#{viewAllInvoicesManagedBean.getAolished()}" var ="l" paginator="true" rows="4">
                                    <p:column style="width:200px;" sortBy="#{o.id}">
                                        <f:facet name="header">Invoice ID</f:facet>
                                        #{l.id}
                                    </p:column>
                                    <p:column sortBy="#{o.invoiceType}">
                                        <f:facet name="header">Type</f:facet>
                                        #{l.invoiceType}
                                    </p:column>   

                                    <p:column>
                                        <f:facet name="header">Company</f:facet>
                                        #{l.deliveryOrder.parentSalesOrder.customer.name}
                                    </p:column>  
                                    <p:column>
                                        <f:facet name ="header">Status</f:facet> 
                                        <h:outputText rendered ="#{l.abolished}" style="color:red;" value="Abolished"/>

                                    </p:column>

                                    <p:column style="width:100px;">
                                        <f:facet name="header">Action</f:facet>

                                        <p:commandButton action ="#{viewAllInvoicesManagedBean.viewInvoice(l)}"  image="ui-icon ui-icon-search" title="View">  
                                        </p:commandButton>

                                    </p:column>        
                                </p:dataTable>


                            </p:fieldset> 
                        </div>   
                    </p:panel>
                </h:form>

            </ui:define>
        </ui:composition>

    </body>
</html>


